<template>
	<view>
		<view class="card" :style="{width:width}">
			<view class="content" @click="handle2GoodsDetail">
				<image class="rectangle" src="/static/icon/rectangle.png"></image>
				<!-- <image class="picture" :src="goodsdata.src_img"></image> -->
				<u-image class="picture" borderRadius="20rpx 20rpx 0 0" width="100%" height="270rpx" :src="img+goodsdata.src_img"></u-image>
				<view class="name"><span>{{goodsdata.title}}</span></view>
			</view>
			<view class="footer">
				<span>¥{{goodsdata.gold}}</span>
				<button type="default" class="exchange_btn" @click="exchange">兑换</button>
			</view>
		</view>
	</view>
</template>

<script>
	import uImage from "@/uview-ui/components/u-image/u-image.vue";
	export default {
		components: {
			uImage
		},
		props: {
			goodsdata: {
				// 列表标题
				type: Object
			},
			width: {
				type: String,
				default: '370rpx'
			}
		},
		data() {
			return {
				img: getApp().globalData.imgbaseUrl
			};
		},
		methods: {
			exchange() {
				this.$emit('exchange', this.goodsdata.class)
			},
			handle2GoodsDetail() {
				this.$emit('handle2Detail', this.goodsdata.id,this.goodsdata.cardname)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		height: 340rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 6rpx 11rpx 1rpx #CACACA;
		margin: 10rpx;
		display: flex;
		flex-direction: column;
		border-radius: 20rpx;

		.content {
			position: relative;

			.name {
				position: absolute;
				width: 100%;
				height: 46rpx;
				bottom: 0;
				background-color: rgba(255, 255, 255, 0.6);
				display: flex;
				align-items: center;

				span {
					color: #191919;
					font-size: 22rpx;
					font-weight: bold;
					padding-left: 16rpx;
				}

			}

			.rectangle {
				position: absolute;
				width: 120rpx;
				height: 120rpx;
				top: 0;
				left: 0;
				z-index: 1;
			}
		}


		.footer {
			display: flex;
			justify-content: space-around;
			align-items: center;
			height: 100rpx;

			span {
				font-size: 20rpx;
				font-weight: bold;
				color: #3B3B3B;
			}

			.exchange_btn {
				background: #07CFD2;
				color: #FFFFFF;
				font-size: 24rpx;
				border-radius: 19rpx;
				height: 38rpx;
				margin: 0;
				display: flex;
				justify-content: center;
				align-items: center;

			}
		}
	}
</style>
